import React, { useState } from "react";
import B from "./B";
//1. 创建 context 对象
export let context = React.createContext();

export default function A() {
  //A 组件的数据
  // let str = 'i love you';
  let [count, setCount] = useState(0);
  return (
    <div>
      <div>A</div>
      <hr />
      {/* 2. 使用 context.Provider 组件包裹后辈组件 传入 value 属性 */}
      <context.Provider value={[count, setCount]}>
        <B />
      </context.Provider>
    </div>
  );
}
